//
//  PKImage.m
//  pkphotomap
//
//  Created by Ed Mancebo on 3/23/11.
//  Copyright 2011 Personal. All rights reserved.
//

#import "PKImage.h"
#import "FlickrAPI.h"

@implementation PKImage

@synthesize imageId, farm, server, secret, title, username, coord;

- (id) initWithImageId:(NSString*)imgid {
	if (self = [super init]) {
		[imgid retain];
		imageId = imgid;
		isInfoLoaded = NO;
	}
	return self;
}

- (void)loadInfo {
	if (!isInfoLoaded) {
		[FlickrAPI setInfo:self];
		isInfoLoaded = YES;
	}
}

- (UIImage*) getThumbImage {
	
	if (thumbImage == nil) {
		thumbImage = [FlickrAPI getImage:self size:@"s"];
		[thumbImage retain];
	}
	
	return thumbImage;
	
}

- (UIImage*) getMedImage {
	
	if (medImage == nil) {
		medImage = [FlickrAPI getImage:self size:nil];
		[medImage retain];
	}
	
	return medImage;
}

- (void) dealloc {
	[imageId release];
	[thumbImage release];
	[medImage release];
	[farm release];
	[server release];
	[secret release];
	
	[super dealloc];
}

@end
